"use strict";
import * as React from 'react';
import { commonStyles } from "../assets/styles/common";
import MyIcon from "./icon";
import MyText from "./MyText";
const { View, TouchableOpacity } = require('react-native');
const { Actions } = require('react-native-router-flux');
class NavBackButton extends React.Component {
    constructor() {
        super(...arguments);
        this.renderChildren = () => {
            if (typeof this.props.children === 'string') {
                return (<View style={commonStyles.backButton}>
                    <MyText color='#fff'>{this.props.children}</MyText>
                </View>);
            }
            else {
                return (<View style={commonStyles.backButton}>
                   {this.props.children}
                </View>);
            }
        };
    }
    render() {
        return (<TouchableOpacity onPress={this.props.onPress}>
                {this.props.children ? this.renderChildren() :
            <View style={commonStyles.backButton}>
                    <MyIcon {...this.props.icon}/>
                </View>}
            </TouchableOpacity>);
    }
}
NavBackButton.defaultProps = {
    icon: { name: 'icon-common-fanhui-copy', color: '#fff', size: 20 },
    onPress: () => { Actions.pop(); }
};
export default NavBackButton;
